# -*- coding: utf-8 -*-
# @Time    : 2024/8/30 下午2:27
# @Author  : wb
# @Email   : wb@163.com
# @File    : client_page
# @Software: PyCharm

from time import sleep
from pages.wb_base_page import BasePage
from selenium.webdriver.common.by import By


class ClientModifyPage(BasePage):
    url = '/crm'
    # 定位器
    '''获取客户名称输入框元素'''
    client_name_locator = (By.CSS_SELECTOR, '#name')
    '''获取放入客户池按钮元素'''
    join_client_pool_locator = (By.ID, 'remove')
    '''获取保存按钮元素'''
    save_locator = (By.CSS_SELECTOR, '#form1 > table > tfoot > tr > td > input.btn.btn-primary')

    # 浏览器操作
    def modify_add_client_pool(self):
        # 点击加入客户池.
        self.driver.find_element(*self.join_client_pool_locator).click()
    sleep(3)
    def modify_clear_client_name(self):
        # 清除客户名称
        self.driver.find_element(*self.client_name_locator).clear()
    def modify_client_alert_accept(self):
        # 处理警告框
        self.driver.switch_to.alert.accept()
        sleep(2)
    def modify_input_client(self,client_name):
        # 修改客户名称为1字符
        self.driver.find_element(*self.client_name_locator).send_keys(client_name)
        sleep(2)
    def modify_save(self):
        # 点击保存
        self.driver.find_element(*self.save_locator).click()
    sleep(3)